/**
 * All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
 * <p>
 * MpmPMOStandardizationRecordServiceAuto
 * PMO标准化人选档案
 * <p>
 * 修改纪录
 * 2021-03-08 版本：1.0 fanzhiming 创建。
 *
 * @version 版本：1.0
 * @author 作者：fanzhiming
 * 创建日期：2021-03-08
 */

package com.topscomm.mpm.service.impl.auto;

import javax.annotation.Resource;

import com.topscomm.basic.IBasicDao;
import com.topscomm.cbo.pojo.CboDeptEntity;
import com.topscomm.cbo.service.impl.CboDeptService;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.SpringUtil;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.tap.common.DatacodeCache;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.topscomm.mpm.*;
import com.topscomm.mpm.pojo.MpmPMOStandardizationRecordEntity;
import com.topscomm.mpm.dao.IMpmPMOStandardizationRecordDao;


public class MpmPMOStandardizationRecordServiceAuto extends MpmService<MpmPMOStandardizationRecordEntity, IMpmPMOStandardizationRecordDao> {

    /**
     * @author: fanzhiming
     * @date: 2021-03-08
     * @param mapRow
     * @description:设置字段显示值
     * @modify:
     */
    @Override
    public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
        String temp;
        if (mapRow.get("usercode") != null) {
            temp = mapRow.get("usercode").toString();
            mapRow.put("dispusercode", datacodeCache.getValueDynamic("CboUser", temp, "code", "name"));
        }
        if (mapRow.get("enabled") != null) {
            temp = mapRow.get("enabled").toString();
            mapRow.put("dispenabled", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
        }
        if (mapRow.get("chargedeptcommoncode") != null) {
            temp = mapRow.get("chargedeptcommoncode").toString();
            List<String> splitList = Arrays.asList(temp.split(","));
            List<String> dispList = new ArrayList<>();
            for (String str : splitList) {
                dispList.add(datacodeCache.getValueDynamic("DeptCommonCodeTrack", str, "code", "name"));
            }
            mapRow.put("dispchargedeptcommoncode", dispList.stream().collect(Collectors.joining(",")));
        }
    }

    @Override
    @Resource(name = "mpmPMOStandardizationRecordDao")
    public void setDao(IBasicDao<MpmPMOStandardizationRecordEntity> dao) {
        super.setDao(dao);
    }
}
